<html>

<head>

  <title>TGroupLayer32</title>

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="../../../../../Styles/Default.css" type="text/css">

  <meta name="Ancestor" content="TLayer32">
<script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shCore.js"></script><script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shBrushDelphi.js"></script><script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shBrushCpp.js"></script><script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shBrushCSharp.js"></script><link rel="stylesheet" type="text/css" href="../../../../../Styles/default.css"/><link rel="stylesheet" type="text/css" href="../../../../../Menu/menu.css"/><link rel="stylesheet" type="text/css" href="../../../../../CodeScripts/SyntaxHighlighter/styles/shCoreDefault.css"/><link rel="stylesheet" type="text/css" href="../../../../../CodeScripts/SyntaxHighlighter/styles/shThemeDefault.css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"><script type="text/javascript" src="../../../../../Menu/menu.js"></script><script type="text/javascript" src="../../../../../CodeScripts/bootstrap.js"></script>
</head>

<body bgcolor="#FFFFFF">
  <div class="menu" id="menu"><a class="ancestor" href="../../../../_Body.htm">Index</a><a class="ancestor" href="../../_Body.htm">Img32.Layers</a><span class="active">TGroupLayer32</span>
  </div><br><br>

  <h1>TGroupLayer32</h1>
  <h2>Ancestors</h2>
  <div class="Hierarchy">&nbsp;&nbsp;&nbsp;|
  </div>
  <div class="Hierarchy"><a href="../TLayer32/_Body.htm">TLayer32</a>
  </div><br><br>

  <p>Apart from the top-most layer (<a href="../TLayeredImage32/Properties/Root.htm"><b>TLayeredImage32.Root</b></a>), all layers are nested within other layers. Nested layers are usually confined to the clipping region of their Parent layer, unless that Parent happens to be a <span class="monobold">TGroupLayer32</span> object. <span class="monobold">TGroupLayer32</span> objects are intended to group related child layers (to simplify their construction and destruction) without confining them to a specific region. Grouping layers also improves rendering performance since they can be blended collectively rather than as individual layers.<br><br> <a href="../TLayeredImage32/Properties/Root.htm"><b>TLayeredImage32.Root</b></a>) is a <span class="monobold">TGroupLayer32</span> that's created automatically when its owner <span class="monobold">TLayeredImage32</span> is created.<br><br> The <span class="monobold">Img32.Layers</span> unit also defines several descendants of <span class="monobold">TGroupLayer32</span> - <a href="../TSizingGroupLayer32/_Body.htm"><b>TSizingGroupLayer32</b></a>, <a href="../TRotatingGroupLayer32/_Body.htm"><b>TRotatingGroupLayer32</b></a> and <a href="../TButtonGroupLayer32/_Body.htm"><b>TButtonGroupLayer32</b></a>.<br><br> Note: Since <span class="monobold">TGroupLayer32</span> is a <a href="../TLayer32/_Body.htm"><b>TLayer32</b></a> descendant, it has an <span class="monobold">Image</span> property. However, this <span class="monobold">Image</span> is used internally and should not be drawn on directly.<br><br> 
    <div class="code">
      <pre class="brush: delphi;">
var
  clickedPoint      : TPoint;
  clickedLayer      : TLayer32;
  targetLayer       : TLayer32;
  sizingbuttongroup : TSizingGroupLayer32;
    
procedure TForm1.FormMouseDown(Sender: TObject; 
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  clickedPoint := Types.Point(X,Y);
  clickedLayer := layeredImage.GetLayerAt(clickedPoint);

  if not Assigned(clickedLayer) then 
  begin
    //destroy any existing sizing buttons
    FreeAndNil(sizingbuttongroup);     
	targetLayer := nil;
  end
  
  //else if clicking on a new target ...
  else if not (clickedLayer is TDesignerLayer32) and 
    (clickedLayer &lt;&gt; targetLayer) then
  begin
    //destroy any existing sizing buttons
    FreeAndNil(sizingbuttongroup);     
	//assigned target
	targetLayer := clickedLayer;
    //create a new group of sizing buttons
	sizingbuttongroup := 
	  CreateSizingButtonGroup(targetLayer,
	    ssCorners, bsRound, DefaultButtonSize, clRed32);
  end;

  //The surface where layeredImage is being 
  //displayed will need refreshing
  Invalidate; 
end;

procedure TForm1.FormMouseMove(Sender: TObject; 
  Shift: TShiftState; X,Y: Integer);
var
  layer  : TLayer32;
  dx, dy : integer;
  rec    : TRect;
begin
  if not (ssLeft in Shift) then
  begin
    layer := layeredImage.GetLayerAt(Types.Point(X,Y));
    if Assigned(layer) then
      Cursor := layer.CursorId else
      Cursor := crDefault;
  end;
  if not Assigned(clickedLayer) then Exit;
  
  dx := X - clickedPoint.X;
  dy := Y - clickedPoint.Y;
  clickedPoint := Types.Point(X,Y);
  
  clickedLayer.Offset(dx, dy);
  
  if (clickedLayer = targetLayer) then
    //also move all the sizing buttons
    sizingbuttongroupbuttongroup.Offset(dx, dy)
  else
  begin
    //respond to a sizing button move ...  
	//UpdateSizingButtonGroup auto-adjusts other 
	//button positions and returns the new BoundsRect
    rec := UpdateSizingButtonGroup(clickedLayer);
    targetLayerLayer.SetBounds(rec);
	//and targetLayer may also need redrawing
  end;  
  
  //The surface where layeredImage is being 
  //displayed will need refreshing
  Invalidate; 
end;

procedure TForm1.FormMouseUp(Sender: TObject; 
  Button: TMouseButton; Shift: TShiftState; 
  X, Y: Integer);
begin
  clickedLayer := nil;
end;
      </pre>
    </div> </p>
  <h2 id="Auto-Reference">Reference</h2>
  <p>
    <table class="autoTbl">
      <tr>
        <th>Methods</th>
        <th style="width: 100%;">Properties</th>
      </tr>
      <tr>
        <td colspan="2" class="ancestor">In TGroupLayer32:
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="Properties/FirstChild.htm">FirstChild</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="Properties/LastChild.htm">LastChild</a>
        </td>
      </tr>
      <tr>
        <td colspan="2" class="ancestor">In TLayer32:
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/AddChild.htm">AddChild</a>
        </td>
        <td><a href="../TLayer32/Properties/BlendFunc.htm">BlendFunc</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/BringForwardOne.htm">BringForwardOne</a>
        </td>
        <td><a href="../TLayer32/Properties/Child.htm">Child</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/BringToFront.htm">BringToFront</a>
        </td>
        <td><a href="../TLayer32/Properties/ChildCount.htm">ChildCount</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/ClearChildren.htm">ClearChildren</a>
        </td>
        <td><a href="../TLayer32/Properties/ClipPath.htm">ClipPath</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/Create.htm">Create</a>
        </td>
        <td><a href="../TLayer32/Properties/CursorId.htm">CursorId</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/DeleteChild.htm">DeleteChild</a>
        </td>
        <td><a href="../TLayer32/Properties/Height.htm">Height</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/Destroy.htm">Destroy</a>
        </td>
        <td><a href="../TLayer32/Properties/Image.htm">Image</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/InsertChild.htm">InsertChild</a>
        </td>
        <td><a href="../TLayer32/Properties/Index.htm">Index</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/Invalidate.htm">Invalidate</a>
        </td>
        <td><a href="../TLayer32/Properties/InnerBounds.htm">InnerBounds</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/MakeAbsolute.htm">MakeAbsolute</a>
        </td>
        <td><a href="../TLayer32/Properties/InnerRect.htm">InnerRect</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/MakeRelative.htm">MakeRelative</a>
        </td>
        <td><a href="../TLayer32/Properties/Left.htm">Left</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/Offset.htm">Offset</a>
        </td>
        <td><a href="../TLayer32/Properties/Location.htm">Location</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/PositionAt.htm">PositionAt</a>
        </td>
        <td><a href="../TLayer32/Properties/MidPoint.htm">MidPoint</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/PositionCenteredAt.htm">PositionCenteredAt</a>
        </td>
        <td><a href="../TLayer32/Properties/Name.htm">Name</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/SendBackOne.htm">SendBackOne</a>
        </td>
        <td><a href="../TLayer32/Properties/Opacity.htm">Opacity</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/SendToBack.htm">SendToBack</a>
        </td>
        <td><a href="../TLayer32/Properties/OuterBounds.htm">OuterBounds</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/SetInnerBounds.htm">SetInnerBounds</a>
        </td>
        <td><a href="../TLayer32/Properties/Parent.htm">Parent</a>
        </td>
      </tr>
      <tr>
        <td><a href="../TLayer32/Methods/SetSize.htm">SetSize</a>
        </td>
        <td><a href="../TLayer32/Properties/Root.htm">Root</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="../TLayer32/Properties/RootOwner.htm">RootOwner</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="../TLayer32/Properties/Top.htm">Top</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="../TLayer32/Properties/UserData.htm">UserData</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="../TLayer32/Properties/Visible.htm">Visible</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="../TLayer32/Properties/Width.htm">Width</a>
        </td>
      </tr>
    </table></p>
  <h2 id="Auto-SeeAlso">See Also</h2>
  <p class="Body"><a href="../TButtonGroupLayer32/_Body.htm">TButtonGroupLayer32</a>, <a href="../TLayer32/_Body.htm">TLayer32</a>, <a href="../TLayeredImage32/Properties/Root.htm">TLayeredImage32.Root</a>, <a href="../TRotatingGroupLayer32/_Body.htm">TRotatingGroupLayer32</a>, <a href="../TSizingGroupLayer32/_Body.htm">TSizingGroupLayer32</a></p>
  <p class="Copyright" id="auto"> <br><br> Copyright &copy;2010-2023 Angus Johnson&nbsp; - &nbsp;Image32 4.2&nbsp; - &nbsp;Help file built on 26 Mar 2023 <br><br> </p>

</body>

</html>